/* ====================================
   组件样式模块 (components.css)
   包含：按钮、表单、卡片、表格等基础组件
   ==================================== */

/* 卡片组件 */
.card { 
    background: var(--color-background);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--box-shadow-md);
    padding: 1.5rem; 
    margin-bottom: 1.5rem;
    border: 1px solid var(--color-border-extra-light);
    transition: box-shadow 0.3s;
}

.card:hover {
    box-shadow: var(--box-shadow-lg);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border-extra-light);
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin: 0;
}

.card-body {
    flex: 1;
}

.card-footer {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border-extra-light);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* 按钮组件 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    border: 1px solid transparent;
    border-radius: var(--border-radius-md);
    transition: all 0.2s;
    text-decoration: none;
    background: transparent;
    outline: none;
    min-height: 32px;
    gap: 0.5rem;
}

.btn:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    color: white;
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.btn-primary:hover:not(:disabled) {
    background-color: #66b1ff;
    border-color: #66b1ff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
}

.btn-success {
    color: white;
    background-color: var(--color-success);
    border-color: var(--color-success);
}

.btn-success:hover:not(:disabled) {
    background-color: #85ce61;
    border-color: #85ce61;
}

.btn-warning {
    color: white;
    background-color: var(--color-warning);
    border-color: var(--color-warning);
}

.btn-warning:hover:not(:disabled) {
    background-color: #ebb563;
    border-color: #ebb563;
}

.btn-danger {
    color: white;
    background-color: var(--color-danger);
    border-color: var(--color-danger);
}

.btn-danger:hover:not(:disabled) {
    background-color: #f78989;
    border-color: #f78989;
}

.btn-secondary {
    color: var(--color-text-primary);
    background-color: var(--color-background);
    border-color: var(--color-border);
}

.btn-secondary:hover:not(:disabled) {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background-color: #ecf5ff;
}

.btn-outline {
    color: var(--color-primary);
    background-color: transparent;
    border-color: var(--color-primary);
}

.btn-outline:hover:not(:disabled) {
    color: white;
    background-color: var(--color-primary);
}

.btn-text {
    color: var(--color-primary);
    background-color: transparent;
    border-color: transparent;
    padding: 0.25rem 0.5rem;
}

.btn-text:hover:not(:disabled) {
    background-color: #ecf5ff;
}

/* 按钮尺寸 */
.btn-small {
    padding: 0.25rem 0.75rem;
    font-size: 12px;
    min-height: 24px;
}

.btn-large {
    padding: 0.75rem 1.5rem;
    font-size: 16px;
    min-height: 40px;
}

/* 表单组件 */
.form-grid { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); 
    gap: 1rem; 
}

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: inline-block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--color-text-primary);
    font-size: 14px;
}

.form-label.required::after {
    content: '*';
    color: var(--color-danger);
    margin-left: 4px;
}

.form-input,
.form-select,
.form-textarea {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 14px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--color-text-primary);
    background-color: var(--color-background);
    background-clip: padding-box;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
    background-color: var(--color-background-lighter);
    opacity: 0.6;
    cursor: not-allowed;
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--color-text-placeholder);
    opacity: 1;
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
}

.form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 12px;
    color: var(--color-text-secondary);
}

.form-error {
    display: block;
    margin-top: 0.25rem;
    font-size: 12px;
    color: var(--color-danger);
}

/* 复选框和单选框 */
.form-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.form-check-input {
    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}

.form-check-label {
    margin: 0;
    cursor: pointer;
    user-select: none;
}

/* 表格组件 */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--color-border-extra-light);
}

.table {
    width: 100%;
    margin-bottom: 0;
    border-collapse: collapse;
    background-color: var(--color-background);
}

.table th,
.table td {
    padding: 0.75rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--color-border-extra-light);
    text-align: left;
}

.table th {
    font-weight: 600;
    color: var(--color-text-primary);
    background-color: var(--color-background-lighter);
    border-bottom: 2px solid var(--color-border-light);
}

.table tbody tr:hover {
    background-color: var(--color-background-light);
}

/* 分页组件 */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    margin-top: 1rem;
}

.pagination-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    min-width: 32px;
    height: 32px;
    font-size: 14px;
    color: var(--color-text-primary);
    background-color: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.pagination-item:hover:not(.disabled):not(.active) {
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.pagination-item.active {
    color: white;
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.pagination-item.disabled {
    color: var(--color-text-placeholder);
    cursor: not-allowed;
    opacity: 0.6;
}

/* 分页容器样式 - 用于区域管理页面 */
.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
    border: 1px solid #dee2e6;
}

.pagination-info {
    font-size: 14px;
    color: #6c757d;
}

.pagination-controls {
    display: flex;
    gap: 5px;
}

.pagination-controls .btn-small {
    padding: 6px 12px;
    font-size: 12px;
    min-width: 36px;
}

.pagination-controls .btn-small:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    font-size: 12px;
    color: #6c757d;
    min-width: 36px;
    justify-content: center;
}

.page-size-selector {
    font-size: 14px;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 5px;
}

.page-size-selector select {
    padding: 4px 8px;
    border: 1px solid #dcdfe6;
    border-radius: 4px;
    background-color: white;
    font-size: 12px;
}

/* 徽章组件 */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    border-radius: 10px;
    text-transform: none;
}

.badge-primary {
    color: white;
    background-color: var(--color-primary);
}

.badge-success {
    color: white;
    background-color: var(--color-success);
}

.badge-warning {
    color: white;
    background-color: var(--color-warning);
}

.badge-danger {
    color: white;
    background-color: var(--color-danger);
}

.badge-secondary {
    color: var(--color-text-primary);
    background-color: var(--color-background-lighter);
}

/* 提示信息组件 */
.alert {
    position: relative;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius-md);
}

.alert-success {
    color: #155724;
    background-color: #d4edda;
    border-color: #c3e6cb;
}

.alert-info {
    color: #0c5460;
    background-color: #d1ecf1;
    border-color: #bee5eb;
}

.alert-warning {
    color: #856404;
    background-color: #fff3cd;
    border-color: #ffeaa7;
}

.alert-danger {
    color: #721c24;
    background-color: #f8d7da;
    border-color: #f5c6cb;
}

/* 工具提示 */
.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 12px;
    border-radius: var(--border-radius-md);
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
}

.tooltip:hover::after {
    opacity: 1;
}

/* ====================================
   策略选择器和区域选择器组件
   ==================================== */

/* 策略选择器样式 */
.strategy-selector {
    position: relative;
}

.strategy-search-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    font-size: 14px;
    padding-right: 30px; /* 为清空按钮留出空间 */
}

.strategy-search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
}

/* 搜索清空按钮 */
.search-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 18px;
    color: var(--color-text-placeholder);
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.search-clear-btn:hover {
    background-color: var(--color-background-light);
    color: var(--color-text-secondary);
}

.search-clear-btn:active {
    background-color: var(--color-border-light);
}

.strategy-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 var(--border-radius-md) var(--border-radius-md);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--box-shadow-md);
}

.strategy-option {
    padding: 0.75rem 0.5rem;
    cursor: pointer;
    border-bottom: 1px solid var(--color-background-light);
    transition: background-color 0.2s;
    position: relative;
}

.strategy-option:hover {
    background-color: var(--color-background-light);
}

.strategy-option:last-child {
    border-bottom: none;
}

.strategy-option.selected {
    background-color: #ecf5ff;
    color: var(--color-primary);
}

/* 策略选项内容分层 */
.strategy-option-name {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--color-text-primary);
    margin-bottom: 2px;
}

.strategy-option-desc {
    display: block;
    font-size: 12px;
    color: var(--color-text-secondary);
    line-height: 1.3;
}

.strategy-option:hover .strategy-option-name {
    color: var(--color-primary);
}

.strategy-option:hover .strategy-option-desc {
    color: var(--color-text-regular);
}

.no-strategy-results {
    padding: 0.75rem 0.5rem;
    text-align: center;
    color: var(--color-text-placeholder);
    font-style: italic;
}

.strategy-selector-compact {
    width: 100%;
    max-width: 280px;
    position: relative;
}

/* 区域选择器样式 */
.area-selector-container {
    position: relative;
}

.area-selector-input {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-md);
    background: var(--color-background);
    cursor: pointer;
    transition: border-color 0.2s;
    min-height: 40px;
}

.area-selector-input:hover {
    border-color: var(--color-primary);
}

.area-selector-input .placeholder {
    color: var(--color-text-placeholder);
}

.area-selector-arrow {
    transition: transform 0.2s;
    color: var(--color-text-secondary);
}

.area-selector-arrow.expanded {
    transform: rotate(180deg);
}

.area-selector-panel {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 var(--border-radius-md) var(--border-radius-md);
    z-index: 1000;
    box-shadow: var(--box-shadow-lg);
    max-height: 400px;
    overflow: hidden;
    display: flex;
}

.area-column {
    flex: 1;
    border-right: 1px solid var(--color-border-light);
    display: flex;
    flex-direction: column;
}

.area-column:last-child {
    border-right: none;
}

.area-column-header {
    padding: 0.75rem;
    background: var(--color-background-lighter);
    border-bottom: 1px solid var(--color-border-light);
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text-primary);
}

.area-options {
    flex: 1;
    overflow-y: auto;
    max-height: 300px;
}

.area-option-container {
    border-bottom: 1px solid var(--color-background-light);
}

.area-option-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
}

.area-name {
    flex: 1;
    cursor: pointer;
    font-size: 14px;
    color: var(--color-text-primary);
}

.area-name:hover {
    color: var(--color-primary);
}

.area-select-btn {
    padding: 0.25rem 0.5rem;
    font-size: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius-sm);
    background: var(--color-background);
    color: var(--color-text-regular);
    cursor: pointer;
    transition: all 0.2s;
}

.area-select-btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.area-select-btn.selected {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.area-option {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--color-background-light);
    transition: background-color 0.2s;
}

.area-option:hover {
    background-color: var(--color-background-light);
}

.area-option.selected {
    background-color: #ecf5ff;
    color: var(--color-primary);
}

.area-clear-btn {
    position: absolute;
    right: 30px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--color-text-placeholder);
    cursor: pointer;
    font-size: 16px;
    padding: 2px;
    border-radius: 50%;
    transition: all 0.2s;
}

.area-clear-btn:hover {
    background: var(--color-background-light);
    color: var(--color-text-secondary);
}

.area-selector-empty {
    padding: 2rem;
    text-align: center;
    color: var(--color-text-placeholder);
    font-style: italic;
}